#include<cstdio>
using namespace std;

int gcd(int x,int y)
{
	if(x==0) return y;
	else return gcd(y%x,x);
}
int main()
{
	int a,b,t;
	scanf("%d%d",&a,&b);
	
	printf("%d\n",gcd(a,b));
	
	return 0;
}
